(function(){"use strict";BX.namespace("BX.Filter");BX.Filter.FieldController=function(t,e){this.field=null;this.parent=null;this.type=null;this.input=null;this.deleteButton=null;this.init(t,e)};BX.Filter.FieldController.prototype={init:function(t,e){if(!BX.type.isDomNode(t)){throw"BX.Filter.FieldController.init: field isn't dom node"}if(!(e instanceof BX.Main.Filter)){throw"BX.Filter.FieldController.init: parent not instance of BX.Main.ui.Filter"}this.field=t;this.parent=e;this.bind();this.isShowDelete()?this.showDelete():this.hideDelete()},isShowDelete:function(){var t=this.getSquares();return this.getInputValue()||BX.type.isArray(t)&&t.length},getField:function(){return this.field},getInput:function(){var t,e;if(!BX.type.isDomNode(this.input)){t=this.getType();e=this.parent.types;if(t===e.DATE){this.input=BX.Filter.Utils.getByClass(this.getField(),this.parent.settings.classDateInput)}if(t===e.NUMBER||t==="number"){this.input=BX.Filter.Utils.getByClass(this.getField(),this.parent.settings.classNumberInput)}if(t===e.STRING){this.input=BX.Filter.Utils.getByClass(this.getField(),this.parent.settings.classStringInput)}if(t===e.CUSTOM_ENTITY){this.input=BX.Filter.Utils.getBySelector(this.getField(),'input[type="hidden"]')}}return this.input},getDeleteButton:function(){if(!BX.type.isDomNode(this.deleteButton)){this.deleteButton=BX.Filter.Utils.getByClass(this.getField(),this.parent.settings.classValueDelete)}return this.deleteButton},getSquares:function(){return BX.Filter.Utils.getByClass(this.getField(),this.parent.settings.classSquare)},bind:function(){if(this.getType()!==this.parent.types.MULTI_SELECT&&this.getType()!==this.parent.types.SELECT){BX.bind(this.getDeleteButton(),"click",BX.delegate(this._onDeleteClick,this));BX.bind(this.getInput(),"input",BX.delegate(this._onInput,this))}},clearInput:function(){var t=this.getInput();if(BX.type.isDomNode(t)){t.value=""}},hideDelete:function(){var t=this.getDeleteButton();if(BX.type.isDomNode(t)){BX.addClass(t,this.parent.settings.classHide)}},showDelete:function(){var t=this.getDeleteButton();if(BX.type.isDomNode(t)){BX.removeClass(t,this.parent.settings.classHide)}},removeSquares:function(){var t=this.getSquares();if(BX.type.isArray(t)&&t.length){t.forEach(function(t){BX.remove(t)})}},_onDeleteClick:function(){this.removeSquares();this.clearInput();this.hideDelete()},_onInput:function(){this.getInputValue()?this.showDelete():this.hideDelete()},getInputValue:function(){var t="";var e=this.getInput();if(BX.type.isDomNode(e)){t=e.value}return t},getType:function(){if(!BX.type.isNotEmptyString(this.type)){this.type=BX.data(this.getField(),"type")}return this.type}}})();
//# sourceMappingURL=field-controller.map.js